package co.com.umobile.network;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

/**
 * Class that validate the conecction.
 * @author Sergio Esteban Granada Restrepo
 * @version 1.0 <BR>
 *          14-October-2010
 * 
 *          This class checks if there is an Internet connection.
 */
public class CheckConnection {

	
	/**
	 * This method checks if there is an Internet connection.
	 * 
	 * @param context context.
	 * @return true if there is an Internet connection.
	 */
	public static boolean isConnected(Context context) {

		ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
		NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();

    if (activeNetworkInfo != null && activeNetworkInfo.isConnectedOrConnecting()) {
      return true;
    } else {
      return false;
    }

	}

}
